<include file="Public/header" />
    <title>关系认证</title>
    <link rel="stylesheet" href="__PUBLIC__/Api/assets/css/reset.css">
    <!-- <script src="__PUBLIC__/Api/assets/js/rem.js"></script> -->
    <link rel="stylesheet" href="__PUBLIC__/Api/assets/css/relation.css">
    <link rel="stylesheet" href="__PUBLIC__/Api/assets/css/font-awesome.min.css">
    <!--<script src="__PUBLIC__/Api/assets/js/jquery-3.3.1.min.js"></script>-->

    <script src="__PUBLIC__/Api/jq.form.js"></script>
</head>

<body>
    <div class="rel-content">
        <div class="rel-header">关系认证<i class="fa fa-angle-left back" onclick="goback()"></i></div>
        <div style="width:100%;margin:10px auto;padding:10px;position: relative;">
            <form method="post" action="" id="form_sub">
                <input required='' id="gzdw" value="<?php echo $arr['gzdw']?>" type='text' name="gzdw">
                <label alt='请输入工作单位' placeholder='工作单位'></label>
                <input required='' id="gzzw" value="<?php echo $arr['gzzw']?>" type='text' name="gzzw">
                <label alt='请输入工作职位' placeholder='工作职位'></label>
                <input required='' id="gzdz" value="<?php echo $arr['gzdz']?>" type='text' name="gzdz">
                <label alt='请输入工作地址' placeholder='工作地址'></label>
                <input required='' id="yx" value="<?php echo $arr['yx']?>" name="yx" type='text'>
                <label alt='月薪' placeholder='月薪'></label>
                <select name="hyzt" class="selectSex" style="width: 200px;
    height: 55px;">
                    <option <?php if($arr['hyzt']=='未婚'){echo 'selected';}?> value="未婚">未婚</option>
                    <option <?php if($arr['hyzt']=='已婚'){echo 'selected';}?> value="已婚" >已婚</option>
                </select>
                <input required='' id="yhpon" value="<?php echo $arr['yhpon']?>" name="yhpon" type='text'>
                <label alt='配偶姓名(选填)' placeholder='配偶姓名(选填)'></label>
                <input required='' id="yhpo" value="<?php echo $arr['yhpo']?>" name="yhpo" type='text'>
                <label alt='配偶手机号码(选填)' placeholder='配偶手机号码(选填)'></label>

                <input required='' id="lxr4n" value="<?php echo $arr['lxr4n']?>" name="lxr4n" type='text'>
                <label alt='亲戚名' placeholder='亲戚名'></label>
                <input required='' id="lxr4" value="<?php echo $arr['lxr4']?>" name="lxr4" type='text'>
                <label alt='亲戚手机号码' placeholder='亲戚手机号码'></label>

                <input required='' id="lxr1n" value="<?php echo $arr['lxr1n']?>" name="lxr1n" type='text'>
                <label alt='紧急联系人(父母兄妹)姓名' placeholder='紧急联系人(父母兄妹)姓名'></label>
                <input required='' id="lxr1" value="<?php echo $arr['lxr1']?>" name="lxr1" type='text'>
                <label alt='紧急联系人(父母兄妹)手机号码' placeholder='紧急联系人(父母兄妹)手机号码'></label>


                <input required='' id="lxr2n" value="<?php echo $arr['lxr2n']?>" name="lxr2n" type='text'>
                <label alt='同事姓名' placeholder='同事姓名'></label>
                <input required='' id="lxr2" value="<?php echo $arr['lxr2']?>" name="lxr2" type='text'>
                <label alt='同事电话号码' placeholder='同事电话号码'></label>


                <input required='' id="lxr3n" value="<?php echo $arr['lxr3n']?>" name="lxr3n" type='text'>
                <label alt='朋友姓名' placeholder='朋友姓名'></label>
                <input required='' id="lxr3" value="<?php echo $arr['lxr3']?>" name="lxr3" type='text'>
                <label alt='朋友电话号码' placeholder='朋友电话号码'></label>


                <button class="rel-submit">提交</button>
                <input type="hidden" name="id" value="<?php echo $arr['id']?>">
            </form>
            <input type="hidden" id="money_y" value="<?php echo $shop['money']?$shop['money']:5000;?>">
        </div>
    </div>
    <script>

        // 验证手机号
        function isPhoneNo(phone) {
            var pattern = /^1[34578]\d{9}$/;
            return pattern.test(phone);
        }
        // 验证中文名称
        function isChinaName(name) {
            var pattern = /^[\u4E00-\u9FA5]{1,6}$/;
            return pattern.test(name);
        }
        $(function () {
            $('.rel-submit').click(function () {
                if(!$('#gzdw').val()){
                    layer.msg('请输入工作单位', {icon: 2});
                    return false;
                }
                if(!$('#gzzw').val()){
                    layer.msg('请输入工作职位', {icon: 2});
                    return false;
                }
                if(!$('#gzdz').val()){
                    layer.msg('请输入工作地址', {icon: 2});
                    return false;
                }

                if(!$('#yx').val()){
                    layer.msg('请输入月薪', {icon: 2});
                    return false;
                }
                if(!isPhoneNo($('#lxr4').val())||!isChinaName($('#lxr4n').val())){
                    layer.msg('亲戚姓名或手机号码不正确!', {icon: 2});
                    return false;
                }

                    //字段合法验证---没有做,需要你做
               if(!isPhoneNo($('#lxr1').val())||!isChinaName($('#lxr1n').val())){
                   layer.msg('紧急联系人姓名或手机号码不正确!', {icon: 2});
                   return false;
               }

                if(!isPhoneNo($('#lxr2').val())||!isChinaName($('#lxr2n').val())){
                    layer.msg('同事姓名或电话号码!', {icon: 2});
                    return false;
                }

                if(!isPhoneNo($('#lxr3').val())||!isChinaName($('#lxr3n').val())){
                    layer.msg('朋友姓名或电话号码不正确!', {icon: 2});
                    return false;
                }



                    //ajax 提交表单
                    $('#form_sub').ajaxSubmit({
                        success:function (abc) {
                            //弹框插件
                            if(abc.type==1){
                                var money=$('#money_y').val();
                                layer.msg("成为会员,借贷金额"+money+"元",{icon:1});
                                setTimeout(function(){
                                    location.href="{:U('index/borrow')}";
                                },4000);
                            }else{
                                layer.msg(abc.msg, {icon: abc.type});
                            }
                        }
                    });
                return false; //阻止表单提交
            })
        });
        function goback() {
            history.go(-1); //返回上一页
        }
    </script>
</body>

</html>
